<?php
require_once("connection.php");
function lay_ds_mon_an_cua_thuc_don($id)
{
    $query="select * from thucdon_monan where ma_thuc_don='$id'";
    $list=mysqli_query(getconn(),$query);
    if (!$list)
    {
        die ('Error statement SQL');
    }
    return $list;
}
function lay_ds_thuc_don_mon_an()
{
    $query="select * from thucdon_monan ";
    $list=mysqli_query(getconn(),$query);
    if (!$list)
    {
        die ('Error statement SQL');
    }
    return $list;
}
function them_thuc_don_mon_an($thucdon)
{
    $query="insert into thucdon_monan values ( ma_thuc_don='{$thucdon['ma_thuc_don']}',
    ma_mon_an='{$thucdon['ma_mon_an']}',trang_thai=1)";
    if(mysqli_query(getconn(),$query))
    return true;
    else return false;
}
function sua_thuc_don_mon_an($thucdon)
{
    $query="update  thucdon_monan set ma thuc_don='{$thucdon['ma_thuc_don']}',
    ma_mon_an='{$thucdon['ma_thuc_don']}',trang_thai={$thucdon['trang_thai']} 
    where ma_td_monan={$thucdon['ma_td_monan']}";
    if(mysqli_query(getconn(),$query))
    return true;
    else return false;
}
function xoa_thuc_don_mon_an($id)
{
    $query="delete from thucdon_monan where ma_td_monan='$id'";
    if(mysqli_query(getconn(),$query))
    return true;
    else return false;
}
?>